# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=h5pyd
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.21.0
pkgrel=1
pkgdesc="h5py distributed - Python client library for HDF Rest API (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/HDFGroup/h5pyd"
msys2_references=(
  'purl: pkg:pypi/h5pyd'
)
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-numpy"
         "${MINGW_PACKAGE_PREFIX}-python-requests-unixsocket"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-pytz"
         "${MINGW_PACKAGE_PREFIX}-python-pyjwt")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-pkgconfig")
optdepends=(#"${MINGW_PACKAGE_PREFIX}-python-msrestazure: extra azure support"
            #"${MINGW_PACKAGE_PREFIX}-python-adal: extra azure support"
            #"${MINGW_PACKAGE_PREFIX}-python-google-api-python-client: extra google support"
            "${MINGW_PACKAGE_PREFIX}-python-google-auth-oauthlib: extra google support"
            "${MINGW_PACKAGE_PREFIX}-python-google-auth: extra google support"
            #"${MINGW_PACKAGE_PREFIX}-python-s3fs: extra aws support"
            "${MINGW_PACKAGE_PREFIX}-python-h5py: extra hdf5 support")
options=('!strip')
source=("https://github.com/HDFGroup/h5pyd/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('b829653608468b3e57c176c1ad64e31bef64ff855b688b7eb750a8746a96212e')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 COPYING \
    "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
